//
//  HEGesturesPWDViewController.m
//  HealthFamily
//
//  Created by 吴欧 on 2021/2/22.
//  Copyright © 2021 honglutec. All rights reserved.
//

#import "HEGesturesPWDViewController.h"
#import "HEGesturesPasswordView.h"
#import "HESecurtyChainData.h"
#import "HELoginViewController.h"

@interface HEGesturesPWDViewController ()<HEGesturesPasswordViewDelegate>

@property (nonatomic, strong) HEGesturesPasswordView *alipay;

@end

@implementation HEGesturesPWDViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    
    self.zx_navLineView.hidden = YES;
    self.title = @"手势密码";
    
    [self dealHandler];
    [self initUI];
}

- (void)initUI {
     _alipay = [[HEGesturesPasswordView alloc] initWithFrame: CGRectMake(0, 0, kScreenWidth, kScreenHeight - ZXNavBarHeight)];
    _alipay.delegate = self;
    _alipay.gestureModel = _gestureModel;
    
    KWeakSelf
    _alipay.block = ^(NSString *pswString) {
        if (weakSelf.gestureModel == HEGesturesPasswordModelValidate) {
            [[UserManager sharedUserManager] reloadMain];
        }else {
            [weakSelf backBtnClicked];
        }
        
        if (weakSelf.backBlock) {
            weakSelf.backBlock();
        }
    };
    
    [self.view addSubview: _alipay];
    
    
    /************************* end **********************************/
    UIButton *backBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    backBtn.frame = CGRectMake(0, 0, 64, 64);
    [backBtn setTitle:@"返回" forState:UIControlStateNormal];
    [backBtn addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:backBtn];
}

- (void)dealHandler {
    
    switch (_gestureModel) {
        case HEGesturesPasswordModelReset:
            [HESecurtyChainData forgotPsw];
            break;
            
        default:
            break;
    }
}

- (void)back  {
    [self backBtnClicked];
}
  
#pragma mark - HEGesturesPasswordViewDelegate
- (void)toSmsLoginHandler {
    HELoginViewController *vc = [HELoginViewController new];
    [self presentViewController:vc animated:YES completion:nil];
}

@end
